Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add a new switch component #960

Open
wants to merge 40 commits into
base: main
Choose a base branch
from

Conversation

JerryWu1234
Copy link
Contributor

What is it?

  • Feature / enhancement
  • Bug
  • Docs / tests
  • Other

Why is it needed?

Checklist:

  • My code follows the developer guidelines of this project
  • I have performed a self-review of my own code
  • I have ran pnpm change and documented my changes
  • I have add necessary docs (if needed)
  • Added new tests to cover the fix / functionality

Copy link

changeset-bot bot commented Sep 13, 2024

🦋 Changeset detected

Latest commit: a10ddbb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@qwik-ui/headless Major
@qwik-ui/styled Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

pkg-pr-new bot commented Sep 13, 2024

Open in Stackblitz

npm i https://pkg.pr.new/qwikifiers/qwik-ui@960
npm i https://pkg.pr.new/qwikifiers/qwik-ui/@qwik-ui/headless@960
npm i https://pkg.pr.new/qwikifiers/qwik-ui/@qwik-ui/styled@960
npm i https://pkg.pr.new/qwikifiers/qwik-ui/@qwik-ui/utils@960

commit: a10ddbb

@JerryWu1234 JerryWu1234 self-assigned this Nov 14, 2024
@JerryWu1234 JerryWu1234 marked this pull request as ready for review December 3, 2024 03:07
@JerryWu1234
Copy link
Contributor Author

image

@thejackshelton
Copy link
Collaborator

Hey Jerry! Just went through the implementation. We're getting close!

A couple of areas of improvement:

  • Clicking outside the thumb (but still on the switch itself), does not toggle the switch
  • When hitting the space key, it will turn on then back off (rather than on like the enter key)
  • Certain accessibility features are missing (https://www.w3.org/WAI/ARIA/apg/patterns/switch/)
  • Every example seems to use a signal bind (this is usually only when the user wants to programmatically change something)

https://kobalte.dev/docs/core/components/switch/

I think this is a good source of inspiration to look at. Along with a set of resources I created here:
https://docs.google.com/document/d/18eA8WfrYtdkrRpavyoG8EmT_uzPtzt24ifOOTKk5In8/edit?tab=t.0

For example, I think it makes a lot of sense to have a new component tied to a piece of markup for the thumb, rather than having it be on a pseudo element, since that would follow the principles of composability. The idea that pieces of markup and components can blend in with each other in a straightforward way.

Atomic Design is a good read if you'd like to look further into it.


I think TDD / adding some tests would help a lot to prevent regressions and keep things robust. We need some tests before we can put the switch component in the beta stage.

@JerryWu1234
Copy link
Contributor Author

Thank you for reviewing, I will fix it soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants